package daoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import dao.BaseDao;
import dao.EmployeeDao;
import entity.Employee;

public class EmployeeDaoImpl extends BaseDao<Employee> implements EmployeeDao {

	public void addEmployee(Connection connection, String sql, Object... args) throws SQLException {
		update(connection,sql,args);
	}

	public void deleteEmployee(Connection connection, String sql, Object... args) throws SQLException {
		update(connection,sql,args);
		
	}

	public void updateEmployee(Connection connection, String sql, Object... args) throws SQLException {
		update(connection,sql,args);
		
	}

	public Employee getEmployeeByEmpId(Connection connection, String sql, Class<Employee> clazz, Object... args) throws SQLException {
		return get(connection, sql, clazz, args);
	}

	public List<Employee> getEmployeeList(Connection connection, String sql, Class<Employee> clazz, Object... args) throws SQLException {
	    return getList(connection, sql, clazz, args);
	}

	public Integer getCount(Connection connection, String sql) throws SQLException {
			PreparedStatement prepareStatement = connection.prepareStatement(sql);
			ResultSet re = prepareStatement.executeQuery();
			int count=0;
			while(re.next()) {
				count = re.getInt("count");
			}
			return count;
	}

	

}
